import G6 from '@antv/g6'
import Minimap from '@antv/g6/lib/plugins/minimap'
import Grid from '@antv/g6/lib/plugins/grid'
import option from './option'
export default class G6Editer {
  constructor(opt) { // constructor是一个构造方法，用来接收参数
    this.opt = opt
    const miniMap = new Minimap({
      size: [300, 200],
      container: 'minimap'
    })
    const grid = new Grid()
    this.opt.plugins = [grid, miniMap]
    this.currentEvent = null
  }
  init(data) {
    this.graph = new G6.Graph(this.opt || option)
    this.graph.data(data)
    this.graph.render()
  }
  getGraph() {
    return this.graph
  }
  add(type, model) {
    this.graph.add(type, model)
  }
  remove(id) {
    this.graph.removeItem(id)
  }
}
